package kr.hkit.PowerJava.chapter13;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.FlowLayout;

import javax.swing.JButton;

public class WindowBuilder_FrameTest extends JFrame {

	private JPanel contentPane;
	private final JPanel tf02 = new JPanel();

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					WindowBuilder_FrameTest frame = new WindowBuilder_FrameTest();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public WindowBuilder_FrameTest() {
		Toolkit tool = Toolkit.getDefaultToolkit();
		Dimension screenSize = tool.getScreenSize();
	    Dimension frameSize = new Dimension(300, 200);
		
		int x =(int)(screenSize.getWidth()/2 - frameSize.getWidth()/2);
		int y =(int)(screenSize.getHeight()/2 - frameSize.getHeight()/2);
		setTitle("윈도우빌더 - 테스트");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(x, y,(int)frameSize.getWidth(), (int) frameSize.getHeight());
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		
		JPanel mainPanel = new JPanel();
		contentPane.add(mainPanel);
		
		JButton btn01 = new JButton("버튼1");
		mainPanel.add(btn01);
		
		JButton btn02 = new JButton("버튼2");
		mainPanel.add(btn02);
		
		JPanel tfpanel = new JPanel();
		contentPane.add(tfpanel);
		
		JPanel tf01 = new JPanel();
		tfpanel.add(tf01);
		tfpanel.add(tf02);
		pack();
	}

}
